import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login' // index.vue是可以省略的
import Layout from '@/views/layout'

import Home from '@/views/home'
import Video from '@/views/video'
import Question from '@/views/question'
import User from '@/views/user'
import Search from '@/views/search'
import SearchResult from '@/views/search/result.vue'
import Article from '@/views/article/index'
import UserProfile from '@/views/user/profile'
import Chat from '@/views/user/chat'
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/',
    name: 'layout',
    component: Layout,
    children: [
      {
        // path: '', // 默认显示的子路由
        // name: 'home',
        // component: Home
        path: '',
        component: Home,
        meta: { isKeepAlive: true }
      },
      {
        path: '/video',
        name: 'video',
        component: Video
      },
      {
        path: '/question',
        name: 'question',
        component: Question
      },
      {
        path: '/user',
        name: 'user',
        component: User
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: Search
  },
  {
    path: '/search/result',
    name: 'SearchResult',
    component: SearchResult
  },
  {
    path: '/article/:id',
    name: 'article',
    component: Article
  },
  {
    path: '/user/profile',
    name: 'userProfile',
    component: UserProfile
    // component: () => import('@/views/user/profile.vue')
  },
  {
    path: '/user/chat',
    name: 'chat',
    component: Chat
  }
  // {
  //   path: '/',
  //   name: 'Home,
  //   component: Home
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  routes
})
export default router
